// 通用移动端适配方法
const fn = () => {
    let viewPort=document.querySelector('mata[name="viewport]');
    let dpr=window.devicePixelRatio || 1;
    dpr=dpr>=3?3:(dpr>=2?2:1);
    let scale=1/dpr;
    let content='width=device-width, initial-scale='+scale+ ' ,user-scalable=no,maximum-scale= '+scale+',minimum-scale='+scale;
    let maxWidth=980;
    let minWidth=320;
    const docuEl = document.documentElement;
    let docuWidth = window.innerWidth;
    const ratio = 7.5;
    docuEl.setAttribute('data-dpr',dpr);
    docuEl.setAttribute('max-width',maxWidth);
    docuEl.setAttribute('min-width',minWidth);
    if(viewPort) {
        viewPort.setAttribute('content',content);
    } else {
        viewPort=document.createElement('meta');
        viewPort.setAttribute('name','viewport');
        viewPort.setAttribute('content',content);
        document.head.appendChild(viewPort);
    }
    if (maxWidth && (docuWidth/dpr>maxWidth)) {
        docuWidth=maxWidth*dpr;
    } else if (minWidth && (docuWidth/dpr<minWidth)) {
        docuWidth=minWidth*dpr;
    }
    const docuRem = docuWidth / ratio;
    docuEl.style.fontSize = docuRem + 'px';
    console.log(`rem=${docuRem}`);
    console.log(document.documentElement.clientWidth);
}
fn();
window.onresize = fn;

// export default fn;